package alibaba;

import java.util.Scanner;

public class Main {

	//字符串比较
	/* 字符串数目为奇数，正常挨个比较，相等输出"YES"不相等输出"NO"
	 * (难点)
	 * 字符串数目若为偶数，string1的前半截与string2的后半截相等并且string1的后半截与string2的前半截相等的情况也算相等（每一半之间递归定义）
	 * 偶数情况例：
	 * 		aabb与bbaa输出是"YES"
	 * 		aaba与abaa输出是"YES"
	 * 		abcbbb与bbbabc输出是"YES"
	 * 		abcbbb与bbbcba输出是"NO"
	 * 		abcdbbbb与bbbbcdab输出是"YES"
	 * 
	 * (最终提交通过80%)
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int count = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < count; i++) {
			String str1 = sc.nextLine();
			String str2 = sc.nextLine();
			if (str1.length() % 2 == 0) {
				if (isEqual(str1, str2)) {
					if (i == 0) {
						sb.append("YES");
					} else {
						sb.append("\nYES");
					}
				} else {
					if (i == 0) {
						sb.append("NO");
					} else {
						sb.append("\nNO");
					}
				}
			}else {
				if (isEqual1(str1, str2)) {
					if (i == 0) {
						sb.append("YES");
					} else {
						sb.append("\nYES");
					}
				} else {
					if (i == 0) {
						sb.append("NO");
					} else {
						sb.append("\nNO");
					}
				}
			}
		}
		System.out.println(sb.toString());
	}

	public static boolean isEqual(String str1, String str2) {
		int len = str1.length();
		if(len % 2 != 0) {
			return isEqual1(str1, str2);
		}
		// 偶数情况
		String subStr11 = str1.substring(0, len / 2);
		String subStr12 = str1.substring(len / 2, len);
		String subStr21 = str2.substring(0, len / 2);
		String subStr22 = str2.substring(len / 2, len);
		if (subStr11.equals(subStr21) && subStr12.equals(subStr22)) {
			return true;
			
		} else if (subStr11.equals(subStr22) && subStr12.equals(subStr21)) {
			return true;	
		} else {
			if(isEqual(subStr11, subStr21) && isEqual(subStr12, subStr22)){
				return true;
			}else if(isEqual(subStr11, subStr22) && isEqual(subStr12, subStr21)){
				return true;
			}
			return false;
		}
	}

	public static boolean isEqual1(String str1, String str2) {
		if (str1.equals(str2)) {
			return true;
		} else {
			return false;
		}
	}
}
